package com.example.my_test_2.service;
import com.example.my_test_2.pojo.Commodity;
import com.example.my_test_2.pojo.Purchase;
import com.example.my_test_2.pojo.User;
import com.example.my_test_2.repos.CommodityRepository;
import com.example.my_test_2.repos.PurchaseRepository;
import com.example.my_test_2.repos.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

//服务层
@Service
public class AdminService {
    @Autowired
    private UserRepository userRepository;


    public List<User> getAllUsers() {
        for (User user : userRepository.findAll()) {
            System.out.println(user);
        }
        return userRepository.findAll();
    }

    @Autowired
    private PurchaseRepository purchaseRepository;

    public List<Purchase> getAllPurchases() {
        return purchaseRepository.findAll();
    }

    @Autowired
    private CommodityRepository commodityRepository;

    public List<Commodity> getAllCommodities() {
        return commodityRepository.findAll();
    }


}





